-
Notifications
You must be signed in to change notification settings - Fork 489
feat: improve ai suggestions #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughReads implemented features from Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant FS as Filesystem
participant Backlog as FeatureLoader
participant AI as AI Service
Client->>Server: request generateSuggestions(projectPath, type)
Server->>FS: read .automaker/app_spec.txt (getAppSpecPath, secureFs)
alt app_spec exists
FS-->>Server: app_spec content
Server->>Server: extractImplementedFeatures(content)
else missing/unreadable
FS-->>Server: error / empty
end
Server->>Backlog: load features from .automaker/features/...
Backlog-->>Server: list of backlog features
Server->>Server: assemble existingContext (implemented + backlog)
Server->>AI: send prompt + existingContext -> request suggestions
AI-->>Server: suggestions
Server-->>Client: filtered/annotated suggestions
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Summary of ChangesHello @Shironex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refines the AI suggestion mechanism by integrating crucial project context directly into the AI's prompt. By feeding the AI information about already implemented features from the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request enhances the AI suggestion feature by incorporating existing context from the project's specification file and backlog. This is a valuable improvement to prevent duplicate task suggestions. The implementation is well-structured into new helper functions. My review includes a few suggestions to refactor parts of the new code to use more modern, declarative JavaScript/TypeScript constructs, which will improve readability and maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/server/src/routes/suggestions/generate-suggestions.ts (1)
18-39: Consider using a proper XML parser instead of regex.Parsing XML with regex is fragile and may fail with comments, CDATA sections, nested structures, or other XML edge cases. Consider using a library like
fast-xml-parseror the built-inDOMParserfor more robust parsing.🔎 Example using fast-xml-parser
+import { XMLParser } from 'fast-xml-parser'; + /** * Extract implemented features from app_spec.txt XML content */ function extractImplementedFeatures(specContent: string): string[] { - const features: string[] = []; - - // Match <implemented_features>...</implemented_features> section - const implementedMatch = specContent.match( - /<implemented_features>([\s\S]*?)<\/implemented_features>/ - ); - - if (implementedMatch) { - const implementedSection = implementedMatch[1]; - - // Extract feature names from <name>...</name> tags - const nameRegex = /<name>(.*?)<\/name>/g; - let match; - - while ((match = nameRegex.exec(implementedSection)) !== null) { - features.push(match[1].trim()); - } + try { + const parser = new XMLParser(); + const parsed = parser.parse(specContent); + + const implementedFeatures = parsed?.implemented_features; + if (!implementedFeatures) return []; + + // Handle both single feature and array of features + const featuresArray = Array.isArray(implementedFeatures) + ? implementedFeatures + : [implementedFeatures]; + + return featuresArray + .map(f => f?.name) + .filter(name => typeof name === 'string') + .map(name => name.trim()); + } catch (error) { + return []; } - - return features; }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/server/src/routes/suggestions/generate-suggestions.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: e2e
🔇 Additional comments (1)
apps/server/src/routes/suggestions/generate-suggestions.ts (1)
132-148: Good integration of existing context into the prompt.The context loading and conditional instruction logic correctly avoids suggesting duplicates when existing features are present. The empty string check on line 138 properly handles the case when no context is available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/server/src/routes/suggestions/generate-suggestions.ts (1)
22-43: Consider using[\s\S]*?in the name regex for consistency.The outer regex correctly uses
[\s\S]*?to match content including newlines, but the inner regex on line 34 uses.*?which doesn't match newlines by default in JavaScript. While feature names spanning multiple lines are unlikely, using/<name>([\s\S]*?)<\/name>/gwould be more consistent and handle edge cases better.Note: XML entities (e.g.,
<,&) and CDATA sections are not decoded/handled by this regex-based approach. This should be fine for the "controlled XML structure" mentioned in the comment, but if feature names start containing special characters that require entity encoding, consider migrating to a proper XML parser as noted in the comments.🔎 Suggested enhancement
- const nameRegex = /<name>(.*?)<\/name>/g; + const nameRegex = /<name>([\s\S]*?)<\/name>/g;
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/server/src/routes/suggestions/generate-suggestions.ts
🧰 Additional context used
🧬 Code graph analysis (1)
apps/server/src/routes/suggestions/generate-suggestions.ts (1)
apps/server/src/services/feature-loader.ts (1)
FeatureLoader(22-384)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: e2e
🔇 Additional comments (2)
apps/server/src/routes/suggestions/generate-suggestions.ts (2)
48-93: Excellent error handling and backward compatibility.The function gracefully handles missing files and read errors with appropriate debug logging, meeting the acceptance criteria for backward compatibility. The implementation correctly:
- Uses
map().join()for cleaner string building (lines 62, 79-85) ✓- Fixes the previous null/undefined issue on line 82 with optional chaining and a fallback to
'Untitled'✓- Returns an empty string when both context sources are unavailable, allowing the caller to proceed without context
137-143: Clean integration of existing context into the prompt.The implementation correctly:
- Awaits the async
loadExistingContextcall- Conditionally includes the duplicate-prevention instruction only when context is present
- Handles the empty-context case gracefully (empty string is falsy, so the ternary on line 143 correctly produces an empty string)
This achieves the PR objective of providing implemented features and backlog context to the AI to minimize duplicate suggestions.
Resolve
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.